{% extends 'xzb/base.html' %}

{% block title %}
	修改密码
{% endblock %}
{% block main %}
	<article>
		<!-- 网站主体 -->
		<div id="main">
			<section class="ct">
				<div class="upload">
					<h1>修改密码</h1>
					<form action="{% url 'modifypass' %}" method="post" id="modify_form">
						{%csrf_token%}
						<div>
							{{ errorMsg }}
						</div>
						<input type="hidden" name="username" value="{{request.session.username}}">
						<p>
							<label>旧密码：</label>
							<input class="upt" type="password" name="oldpassword" id="old_password" value="" placeholder="请输入原密码"/>
							<em></em>
						</p>
						<p>
							<label>新密码：</label>
							<input class="upt" type="password" name="password" id="new_password" value="" placeholder="请输入新密码"/>
							<em></em>
							<span class="source-tag-msg">密码长度为6~20</span>
						</p>
						<p>
							<label>确认密码：</label>
							<input class="upt" type="password" name="enterpassword" id="enter_password" value="" placeholder="请再次输入新密码"/>
							<em></em>
							<span class="source-tag-msg">两次输入的密码必须保持一致</span>
						</p>
						
						<p><label class="btn"><a class="btn" id="modify_tbn">确认修改</a></label></p>
					</form>
				</div>
			</section>	
		</div>
	</article>

	<script>
	$(function(){
		$("#modify_tbn").click(function(){
			let oldpassword = $("#old_password").val();
			if(oldpassword == undefined || oldpassword == ""){
				alert("旧密码不能为空");
				return;
			}
			let newpassword = $("#new_password").val();
			if(newpassword == undefined || newpassword == ""){
				alert("新密码不能为空");
				return;
			}
			let enterpassword = $("#enter_password").val();
			if(enterpassword == undefined || enterpassword == ""){
				alert("确认密码不能为空");
				return;
			}
			if(enterpassword != newpassword){
				alert("密码不一致");
				return;
			}
			$("#modify_form").submit();
	})
	})
	</script>
{% endblock %}
	<footer>
		<p class="decro">本站所有资源信息均由网友上传,本站只是为了推广资源让更多读者下载,使用。如涉侵权，请联系管理员</p>
		<p class="cr">Copyright © 2021-2025 <span class="site">爱下载资源分享平台</span> All Rights Reserved.</p>
		<p class="num">沪ICP备14048333号</p>
	</footer>